﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using CGeers.Wcf.Services;
using CGeers.Wcf.Services.Preprocesslanguage;

namespace ConsoleHost
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Server is reading data...");
            Ngram.readData("1word_P.txt", "2word_P.txt", "3word_P.txt");
            NgramN.readData("1word_P.txt", "1word_US2S.txt","2word_US2S.txt", "3word_US2S.txt");
            ProcessPragraph.readData("wordLinked.txt");
            Console.WriteLine("Complete.");
            Console.WriteLine("=============Server config=============");
            Console.WriteLine("\t1.Ngram");
            Console.WriteLine("\t2.Ngram and WordLink");
            Console.WriteLine("\t3.NgramNew");
            Console.WriteLine("\t4.NgramNew and WordLink");
            Console.WriteLine("================Command================");
            Console.Write("User choice:");
            string cmd = "";
            switch (cmd=Console.ReadLine())
            {
                case "1":
                    ProcessPragraph.IsNgramNew = false;
                    ProcessPragraph.IsWordLinked = false;
                    Ngram.allowDelCount = true;
                    Ngram.countDel = 5;
                    break;
                case "2":
                    ProcessPragraph.IsNgramNew = false;
                    ProcessPragraph.IsWordLinked = true;
                    Console.WriteLine(ProcessPragraph.IsWordLinked);
                    Ngram.allowDelCount = true;
                    Ngram.countDel = 5;
                    break;
                case "3":
                    ProcessPragraph.IsNgramNew = true;
                    ProcessPragraph.IsWordLinked = false;
                    Ngram.allowDelCount = true;
                    Ngram.countDel = 5;
                    break;
                case "4":
                    ProcessPragraph.IsNgramNew = true;
                    ProcessPragraph.IsWordLinked = true;
                    Ngram.allowDelCount = true;
                    Ngram.countDel = 5;
                    break;
                default:
                    Console.WriteLine("Don't have command. System will use default config.");
                    ProcessPragraph.IsNgramNew = true;
                    ProcessPragraph.IsWordLinked = true;
                    Ngram.allowDelCount = true;
                    Ngram.countDel = 5;
                    break;
            }
            ServiceHost host = new ServiceHost(typeof(DemoServer));
            Console.WriteLine("Demo Server Service Host");
            host.Open();
            Console.WriteLine("Service Started!");
            foreach (Uri address in host.BaseAddresses)
            {
                Console.WriteLine("Listening on " + address);
            }
            Console.WriteLine("Press any key to close the host...");
            Console.ReadLine();
            host.Close();
        }
    }
}
